package com.mzy.tomcat.servlet;

import com.mzy.tomcat.annotation.WebServlet;
import com.mzy.tomcat.http.MzyHttpRequest;
import com.mzy.tomcat.http.MzyHttpResponse;
import com.mzy.tomcat.utils.WebUtils;

import java.io.IOException;

@WebServlet("/demo")
public class MzyCalServlet extends MzyHttpServlet {
    @Override
    public void doPost(MzyHttpRequest request, MzyHttpResponse response) throws IOException {
        this.doGet(request, response);
    }

    @Override
    public void doGet(MzyHttpRequest request, MzyHttpResponse response) throws IOException {
        int num1 = WebUtils.parseInt(((String) request.getAttribute("num1")));
        int num2 = WebUtils.parseInt(((String) request.getAttribute("num2")));
        System.out.println(num1 + num2);
        response.write(num1 + num2 + "");
    }

    @Override
    public void init() {

    }

    @Override
    public void destroy() {

    }
}
